* load TIMSS test scores from wbopendata
* 	(Trends in International Mathematics and Science Study)
*   and PIRLS (Progress in International Reading Literacy Study)

cd "~/Documents/econ/research/current/cognitive/estimation/data"

wbopendata, long year(2000:2019) clear nometadata indicator( ///
	lo.timss.sci4; lo.timss.sci4.low; lo.timss.sci4.bl;  ///
	lo.timss.mat4; lo.timss.mat4.low; lo.timss.mat4.bl;  ///
	lo.pirls.rea; lo.pirls.rea.low; lo.pirls.rea.bl;	 ///
	se.xpd.prim.pc.zs; se.xpd.totl.gd.zs)                       
//	lo.pisa.mat; lo.pisa.rea; lo.pisa.sci) // pisa for 2018
//  LO.SACMEQ.MAT LO.SACMEQ.REA  S & E African 6th graders
rename lo_timss_sci4 	 timsssci
rename lo_timss_sci4_low timsssci_lo
rename lo_timss_sci4_bl  timsssci_bl
rename lo_timss_mat4 	 timssmat
rename lo_timss_mat4_low timssmat_lo
rename lo_timss_mat4_bl  timssmat_bl
rename lo_pirls_rea  	 pirlsread
rename lo_pirls_rea_low	 pirlsread_lo
rename lo_pirls_rea_bl	 pirlsread_bl
rename se_xpd_prim_pc_zs pri_ed_exp_pct
rename se_xpd_totl_gd_zs ed_exp_pct
label var timsssci "TIMSS science score, 4th grade"
label var timsssci_lo "% w/low TIMSS science score, 4th grade"
label var timsssci_bl "% below low TIMSS science score, 4th grade"
label var timssmat "TIMSS math score, 4th grade"
label var timssmat_lo "% w/low TIMSS math score, 4th grade"
label var timssmat_bl "% below low TIMSS math score, 4th grade"
label var pirlsread "PIRLS reading score, 4th grade"
label var pirlsread_lo "% w/low PIRLS reading score, 4th grade"
label var pirlsread_bl "% below low PIRLS reading score, 4th grade"
label var pri_ed_exp_pct "Primary educ. govt. expenditure/student (% GDP p.c.)"
label var ed_exp_pct "Educ. govt expenditure (% of GDP)"
keep if timssmat<. | pirlsread<.
keep countrycode year timss* pirls* pri_ed_exp_pct ed_exp_pct
sort countrycode year 
save timss, replace
